import { Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { CheckbaseComponent } from '../core/api';

@Component({
  selector: 'lv-radio, [lv-radio], [lvRadio',
  exportAs: 'lvRadio',
  templateUrl: '../core/checkbase/checkbase.component.html',
  encapsulation: ViewEncapsulation.None,
  changeDetection: ChangeDetectionStrategy.OnPush,
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef((): typeof RadioComponent => RadioComponent),
      multi: true,
    },
  ],
  host: {
    '[class.lv-checkbase]': 'true',
    '[class.lv-checkbase-checked]': 'checked === true',
    '[class.lv-checkbase-button]': 'lvViewType === "button"',
    '[attr.disabled]': 'disabled ? "" : null',
    '(click)': '_click($event)',
  },
})
export class RadioComponent extends CheckbaseComponent implements OnInit {
  ngOnInit(): void {
    this.type = 'radio';
  }

  markForCheck(): void {
    this.cdr.markForCheck();
  }
}
